<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAdminRouteTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('admin_route', function (Blueprint $table) {
            $table->increments('route_id');
            $table->string('name')->unique()->comment('路由名');
            $table->string('path')->nullable()->comment('路由路径');
            $table->string('redirect')->nullable()->comment('当设置 noredirect 的时候该路由在面包屑导航中不可被点击');
            $table->string('title', 200)->nullable()->comment('设置该路由在侧边栏和面包屑中展示的名字');
            $table->string('icon', 100)->nullable()->comment('设置该路由的图标');
            $table->tinyInteger('hidden')->default(0)->comment('当设置 true 的时候该路由不会再侧边栏出现 如401，login等页面，或者如一些编辑页面/edit/1');
            $table->tinyInteger('always_show')->default(0)->comment('你可以设置 alwaysShow: true，这样它就会忽略之前定义的规则，一直显示根路由');
            $table->tinyInteger('no_cache')->default(0)->comment('如果设置为true，则不会被缓存(默认 false)');
            $table->tinyInteger('affix')->default(0)->comment('affix为1时tag会被固定在 tags-view中（不可以被删除）默认为false');
            $table->tinyInteger('breadcrumb')->default(1)->comment('如果设置为false，则不会在breadcrumb面包屑中显示');
            $table->timestamps();
            $table->index('title');
        });

        \Illuminate\Support\Facades\DB::statement("ALTER TABLE admin_route AUTO_INCREMENT=100");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('admin_route');
    }
}
